package com.hm.add2;

import java.util.ArrayList;
import java.util.Collections;

public class Test {
    public static void main(String[] args) {
        Drink d1=new Beer("青岛冰醇啤酒600ml",3.5);
        Drink d2 = new Coffee("蓝山咖啡350ml", 199);
        ArrayList<Drink> list = new ArrayList<>();
        Collections.addAll(list,d1,d2);
        for (Drink drink : list) {
            if(drink instanceof Beer beer){
                beer.taste();
                double lotto = beer.lotto();
                System.out.println("优惠金额为"+lotto);
            }else{
                Coffee coffee = (Coffee) drink;
                coffee.taste();
                double lotto = coffee.lotto();
                System.out.println("优惠金额为"+lotto);
            }
        }

    }
}
